package com.sxpi.chapter02.service.order;

import com.sxpi.chapter02.mode.*;
import com.sxpi.chapter02.mode.factory.UserVipServiceFactory;
import com.sxpi.chapter02.pojo.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Author: 董伟豪
 * @Date: 2023/2/4 12:53
 */
@Service
@Slf4j
public class OrderServiceImpl implements IOrderService{

    @Override
    public String buyCourse(User user, Long courseId) {
        Double coursePrice = 100D;
        Integer cron = 0;

        IUserVipService userVipService = UserVipServiceFactory.getInstance(user.getVip());
        // 通过计算后会把课程金额算进去进行支付
        log.info("用户的身份是：{}，购买了课程价格：{}，积分是：{}", user.getId(),userVipService.getMoney(100D),userVipService.getCorn());
        return "success";
    }
}
